<?php

/**
 * sfGuardUserAdminForm for admin generators
 *
 * @package    sfDoctrineGuardPlugin
 * @subpackage form
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: sfGuardUserAdminForm.class.php 23536 2009-11-02 21:41:21Z Kris.Wallsmith $
 */
class sfGuardUserAdminForm extends BasesfGuardUserAdminForm {

    /**
     * @see sfForm
     */
    public function configure() {
        $dadosUser = sfContext::getInstance()->getUser()->getGuardUser();
        $this->widgetSchema['is_active2'] = new sfWidgetFormInputHidden();
        $this->widgetSchema['groups_list2'] = new sfWidgetFormInputHidden();
        $this->validatorSchema['is_active2'] = new sfValidatorString(array('max_length' => 1, 'required' => false));
        $this->validatorSchema['groups_list2'] = new sfValidatorString(array('max_length' => 1, 'required' => false));
        if (!$dadosUser->getIsSuperAdmin()) {
            $this->widgetSchema['groups_list2'] = new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardGroup'));
            $this->setDefault('groups_list2', $this->object->Groups->getPrimaryKeys());
            $this->widgetSchema['is_active2'] = new sfWidgetFormInputCheckbox(array(), array('checked' => $dadosUser->getIsActive(), 'disabled' => 'disabled'));
            unset(
                    $this['is_super_admin'], $this['is_active'], $this['groups_list']
            );
            $this->widgetSchema['groups_list2']->setAttribute('disabled', 'disabled');
        }
    }

}
